package br.com.puertorico.mecanismos.ui.validators;

import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;

public class IdValidator extends BaseValidator implements Validator {

	@Override
	public void validate(FacesContext ctx, UIComponent comp, Object value)
			throws ValidatorException {
		Long id = Long.parseLong(value.toString());

		if (id < 1) {
			FacesMessage facesMsg = new FacesMessage(
					FacesMessage.SEVERITY_ERROR, "", getMessage(value));
			throw new ValidatorException(facesMsg);
		}
	}
}
